import 'package:flutter_common_fragement/common/base/index.dart';
import 'package:flutter_common_fragement/pages/root_view_model.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:provider/provider.dart';

class RootPage extends BasePage<RootViewModel> {
  RootPage() : super(RootViewModel());

  @override
  Widget build(BuildContext context) {
    return Consumer<RootViewModel>(builder: (context, vm, _) {
      return WillPopScope(
        onWillPop: vm.willPop,
        child: Scaffold(
          body: PageView(
            controller: vm.pageController,
            physics: const NeverScrollableScrollPhysics(),
            children: vm.navViews,
          ),
          bottomNavigationBar: BottomNavigationBar(
            type: BottomNavigationBarType.fixed,
            currentIndex: vm.currentIndex,
            items: vm.navBottomItems,
            selectedFontSize: 10.sp,
            unselectedFontSize: 10.sp,
            onTap: vm.setCurrentIndex,
            showUnselectedLabels: true,
          ),
        ),
      );
    });
  }
}
